package com.woniuxy.micropermissionserver.rolemanage.controller;

import com.woniuxy.microcommonserver.bean.permission_hcz.Role;
import com.woniuxy.microcommonserver.res.ResultMsg;
import com.woniuxy.micropermissionserver.rolemanage.service.IRoleService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;

@RestController
@RequestMapping("role")
public class RoleController {


    @Resource
    private IRoleService roleService;


    @PostMapping("add")
    public ResultMsg addRole(Role role, @RequestParam("permissionIds[]") Integer[] permissionIds) {
        roleService.saveRole(role, new ArrayList<>(Arrays.asList(permissionIds)));
        return new ResultMsg(200, "success", null);
    }
}
